package com.umeng.community.example;

import android.content.Intent;
import android.os.Bundle;

import com.qianxx.base.BaseActivity;
import com.qianxx.base.utils.SPUtil;
import com.qianxx.draw.R;

/**
 * 启动页(显示时间暂时设置为1秒)
 * */
public class SplashAty extends BaseActivity {

	private static final int sleepTime = 1000;

	@Override
	protected void onCreate(Bundle arg0) {
		super.onCreate(arg0);
		setContentView(R.layout.aty_splash);
	}

	@Override
	protected void onStart() {
		super.onStart();
		new Thread(new Runnable() {
			public void run() {
				try {
					Thread.sleep(sleepTime);
				} catch (InterruptedException e) {
				}
				skipToWhere();
			}
		}).start();
	}


	@Override
	protected void onPause() {
		super.onPause();
	}

	private void skipToWhere() {
		boolean isFirst = SPUtil.getInstance().isFirst();
		if (!isFirst) {
			// 非首次进入，直接跳转首页
			skipToMain();
			finish();
			return;
		}
		skipToGuide();
	}

	// 跳转主页
	private void skipToMain() {
		Intent intent = new Intent(SplashAty.this, MainActivity.class);
		startActivity(intent);
		finish();
	}

	// 跳转引导页
	private void skipToGuide() {
		Intent intent = new Intent(SplashAty.this, GuideAty.class);
		startActivity(intent);
		finish();
	}

}
